priority -50

extends rmd2

global !p
def create_table(snip):
    # retrieving single line from current string and treat it like tabstops count
    placeholders_string = snip.buffer[snip.line].strip()[2:].split("x",1)
    rows_amount = int(placeholders_string[0])
    columns_amount = int(placeholders_string[1])

    # erase current line
    snip.buffer[snip.line] = ''

    # create anonymous snippet with expected content and number of tabstops
    anon_snippet_title = ' | '.join(['$' + str(col) for col in range(1,columns_amount+1)]) + "\n"
    anon_snippet_delimiter = ':-|' * (columns_amount-1) + ":-\n"
    anon_snippet_body = ""
    for row in range(1,rows_amount+1):
        anon_snippet_body += ' | '.join(['$' + str(row*columns_amount+col) for col in range(1,columns_amount+1)]) + "\n"
    anon_snippet_table = anon_snippet_title + anon_snippet_delimiter + anon_snippet_body

    # expand anonymous snippet
    snip.expand_anon(anon_snippet_table)
endglobal

global !p
texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']]

texIgnoreMathZones = ['texMathText']

texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')")
texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')")

ignore = texIgnoreMathZoneIds[0]

def math():
	synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))")
	try:
		first = next(i for i in reversed(synstackids) if i in texIgnoreMathZoneIds or i in texMathZoneIds)
		return first != ignore
	except StopIteration:
		return False
endglobal

################
#  ganx@swufe  #
################

snippet enum "Enumerate with (a) by ganx" bA
	(a) $1
	(a) $2
$0
endsnippet

snippet qb "Enumerate with (a) by ganx" bA
1. $1
$0
endsnippet

snippet qn "Enumerate with (a) by ganx" bA
1. $1
	(a) $2
	(a) $3
$0
endsnippet

snippet 'dif "dif by ganx" wA
\mathop{}\!\mathrm{d}
endsnippet

snippet x0 "notation x>=0" w
$${1:x}($1\ge0)$
endsnippet

snippet ul "underline by ganx" w
\`r underline()\`
endsnippet


##################################
#  Calculus (reserved letter: c  #
##################################

snippet 'ci "integral by ganx" iA
\int_{${1:-\infty}}^{${2:}} ${3:${VISUAL}}\,{\rm d}$0
endsnippet

######################################
#  Environment (reserved letter: e)  #
######################################

snippet ali "aligned envionment by ganx" bA
\begin{align*}
	 & ${1:${VISUAL}} \\\\
	=& $2 \\\\
	=& $3.
\end{align*}$0
endsnippet

snippet beg "begin{} / end{} by ganx" bA
\\begin{$1}\label{$2}
	$0
\\end{$1}
endsnippet

snippet eql "Labeled equation environment by ganx"
\begin{equation} \label{eq:${1}}
	${0:${VISUAL}}
\end{equation}
endsnippet

snippet table "Table environment by ganx" b
\begin{table}[${1:htpb}]
	\centering
	$0
	\caption{${2:caption}}
	\label{tab:${3:label}}
\end{table}
endsnippet


######################################################
#  Text related auto-expansion (reserved letter: t)  #
######################################################

snippet lz "\noindent\textbf{例15~~} by ganx" iA
\noindent\textbf{例$1~~}~$0
endsnippet

snippet 'tq "quote text by ganx" iA
\`\`${1:${VISUAL:text}}'' ${0}
endsnippet

snippet ita "italic text"
*${1:${VISUAL:text}}*${0}
endsnippet

snippet bf "bold face text"
**${1:${VISUAL:text}}**${0}
endsnippet

snippet under "underline text"
\underline{${1:${VISUAL:text}}}${0}
endsnippet
snippet over "overline text"
\overline{${1:${VISUAL:text}}}${0}
endsnippet
snippet emp "emphasize text by ganx"
\emph{${1:${VISUAL:text}}}~${0}
endsnippet
snippet sc "small caps text"
\textsc{${1:${VISUAL:text}}}${0}
endsnippet
#Choosing font
snippet sf "sans serife text"
\textsf{${1:${VISUAL:text}}}${0}
endsnippet
snippet rm "roman font text"
\textrm{${1:${VISUAL:text}}}${0}
endsnippet
snippet tt "typewriter (monospace) text"
\texttt{${1:${VISUAL:text}}}${0}
endsnippet

snippet ll "two newlines by ganx" iw
&NewLine;
&NewLine;

$0
endsnippet

#################################
#  math related auto-expansion  #
#################################

context "math()"
snippet 'bf "boldface" iA
\mathbf{${1:${VISUAL}}}${0}
endsnippet

snippet 'mpit "math pi(theta) by ganx" iA
$\pi(\theta)$
endsnippet

snippet 'mx "math x by ganx" iA
$x$
endsnippet

########################################
#  Greek letters (rererved letter: g)  #
########################################
snippet 'ga "alpha by ganx" iA
\alpha
endsnippet

snippet 'gb "beta by ganx" iA
\beta
endsnippet

snippet 'gd "delta by ganx" iA
\delta
endsnippet

snippet 'mgd "delta by ganx" iA
\delta
endsnippet

snippet 'gD "Delta by ganx" iA
\Delta
endsnippet

snippet 'ge "epsilon by ganx" iA
\epsilon
endsnippet

snippet 'gs "sigma by ganx" iA
\sigma
endsnippet

snippet 'gt "theta by ganx" iA
\theta
endsnippet

snippet 'mgt "theta by ganx" iwA
$\theta$ 
endsnippet

snippet 'gT "Theta by ganx" iA
\Theta
endsnippet

snippet 'gy "gamma by ganx" iA
\gamma
endsnippet

snippet 'gz "zeta" iA
\zeta
endsnippet
#Formating text: italic, bold, underline, small capital, emphase ..
snippet ita "italic text"
\textit{${1:${VISUAL:text}}}${0}
endsnippet
snippet bfl "bold face text"
\textbf{${1:${VISUAL:text}}}${0}
endsnippet
snippet bfcl "bold face text"
\textbf{${1:${VISUAL:text}}}~${0}
endsnippet
snippet under "underline text"
\underline{${1:${VISUAL:text}}}${0}
endsnippet
snippet over "overline text"
\overline{${1:${VISUAL:text}}}${0}
endsnippet
snippet emp "emphasize text by ganx"
\emph{${1:${VISUAL:text}}}~${0}
endsnippet
snippet sc "small caps text"
\textsc{${1:${VISUAL:text}}}${0}
endsnippet
#Choosing font
snippet sf "sans serife text"
\textsf{${1:${VISUAL:text}}}${0}
endsnippet
snippet rm "roman font text"
\textrm{${1:${VISUAL:text}}}${0}
endsnippet
snippet tt "typewriter (monospace) text"
\texttt{${1:${VISUAL:text}}}${0}
endsnippet

#Math font

context "math()"
snippet mcal "mathcal by castel" iA
\mathcal{$1}$0
endsnippet

context "math()"
snippet mrak "mathfrak by ganx" iA
\mathfrak{$1}$0
endsnippet

context "math()"
snippet mbb "mathbb by ganx" iA
\mathbb{$1}$0
endsnippet

context "math()"
snippet mscr "mathscr by ganx" iA
\mathscr{$1}$0
endsnippet

#####################################################
#  Probability and Statistics (Reserved letter: p)  #
#####################################################

snippet 'mE "random variable X by ganx" iA
$\mathbb{E}\{${1:${VISUAL}}\}$$0
endsnippet

snippet 'E "random variable X by ganx" iA
\mathbb{E}\{${1:${VISUAL}}\}$0
endsnippet

snippet 'pcf "conditional prob. dist. fun by ganx" iA
f(x|\theta)
endsnippet

snippet 'mpcf "math conditional prob. dist. fun by ganx" iwA
$f(x|\theta)$
endsnippet

snippet 'pcF "conditional cumulative dist. fun by ganx" iA
F(x|\theta)
endsnippet

snippet 'mpcF "math conditional cumulative dist. fun by ganx" iA
$F(x|\theta)$
endsnippet

snippet 'mpp "math posterior dist. fun by ganx" iA
$\pi(x|\theta)$
endsnippet

snippet 'pp "posterior dist. fun by ganx" iA
\pi(x|\theta)
endsnippet

snippet 'mbi "binom{}{} by ganx" iA
\binom{${1:n}}{${2:x}}$0
endsnippet

snippet 'mP "random variable X by ganx" iA
$\mathbb{P}\{${1:${VISUAL}}\}$$0
endsnippet

snippet 'P "random variable X by ganx" iA
\mathbb{P}\{${1:${VISUAL}}\}$0
endsnippet

snippet 'pbi "Binomial distribution by ganx" iA
\mathscr{B}(n,\theta)
endsnippet

snippet 'pn "Normal distribution by ganx" iA
\mathscr{N}($1,$2)$0
endsnippet

snippet 'X "random variable X by ganx" iA
$\mathbf{X}$
endsnippet
#########################
#  Terms in math & Stat #
#########################

snippet Bay "Bayesiain analysis"
Bayesian analysis
endsnippet

snippet Lik "Likelihood Principle"
Likelihood Principle 
endsnippet

snippet pos "posterior distribution"
posterior distribution
endsnippet

snippet prid "prior distribution"
prior distribution
endsnippet

snippet pri "prior information"
prior information
endsnippet

snippet Pri "Prior information"
Prior information
endsnippet

snippet samp "sample information"
sample information
endsnippet

snippet Samp "Sample information"
Sample information
endsnippet

snippet suf "sufficient statistic"
sufficient statistic
endsnippet

snippet Suf "Sufficient statistic"
Sufficient statistic
endsnippet

#################
#  expressions  #
#################

snippet 'am "AP order shceme" iA
(Z,\hat{x})
endsnippet

context "math()"
snippet aa "(a_1,a_2,\ldots,a_n)" iA
(a_1,a_2,\ldots,a_n)$0
endsnippet

snippet i= "$i=1,2,\ldots,n$ by ganx" w
$${1:i}=1,2,\ldots,${2:n}$$0 
endsnippet

snippet j= "$j=1,2,\ldots,n$ by ganx" w
$${1:j}=1,2,\ldots,${2:n}$$0 
endsnippet

snippet 'kc "$K$-convex" wA
$K$-convex
endsnippet

snippet 'ky "$K$-convexity" wA
$K$-convexity
endsnippet

snippet 'ly "$L(y)$" wA
$L(y)$
endsnippet

snippet 'rf "Risk function R(\theta,\delta)" w
R(\theta,\delta) 
endsnippet

snippet 'mrf "Risk function R(\theta,\delta)" w
$R(\theta,\delta)$ 
endsnippet

context "math()"
snippet sen "{1,2,\ldots,n}" iA
\{1,2,\ldots,n\}$0
endsnippet

context "math()"
snippet sea "{a_1,a_2,\ldots,a_n}" iA
\{a_1,a_2,\ldots,a_n\}$0
endsnippet


###################
#  ganxCasteltex  #
###################


snippet mk "Math revised by ganx" wA
$${1}$`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ')', ' ']:
	snip.rv = ' '
else:
	snip.rv = ''
`$2
endsnippet

snippet dm "Math" wA
$$${1:${VISUAL}}$$
$0
endsnippet

context "math()"
snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet

snippet / "Fraction" i
\\frac{${VISUAL}}{$1}$0
endsnippet

context "math()"
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "symbol frac" wrA
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
endsnippet

context "math()"
snippet ceil "ceil" iA
\left\lceil $1 \right\rceil$0
endsnippet

context "math()"
snippet floor "floor" iA
\left\lfloor $1 \right\rfloor$0
endsnippet

snippet pmat "pmat" iA
\begin{pmatrix} $1 \end{pmatrix}$0
endsnippet

snippet bmat "bmat" iA
\begin{bmatrix} $1 \end{bmatrix}$0
endsnippet

context "math()"
snippet () "left( right)" iA
\left( ${1:${VISUAL}}\right)$0
endsnippet

snippet lr "left( right)" i
\left( ${1:${VISUAL}}\right)$0
endsnippet

snippet lr( "left( right)" i
\left( ${1:${VISUAL}}\right)$0
endsnippet

snippet lr| "left| right|" i
\left| ${1:${VISUAL}}\right|$0
endsnippet

snippet lr{ "left\{ right\}" i
\left\\{ ${1:${VISUAL}}\right\\}$0
endsnippet

snippet lrb "left\{ right\}" i
\left\\{ ${1:${VISUAL}}\right\\}$0
endsnippet

snippet lr[ "left[ right]" i
\left[ ${1:${VISUAL}}\right]$0
endsnippet

snippet lra "leftangle rightangle" iA
\left<${1:${VISUAL}}\right>$0
endsnippet

context "math()"
snippet conj "conjugate" iA
\overline{$1}$0
endsnippet

snippet sum "sum by ganx" w
\sum_{${1:i}=${2:1}}^{${3:n}} ${4:a_n z^n}
endsnippet

snippet taylor "taylor" w
\sum_{${1:k}=${2:0}}^{${3:\infty}} ${4:c_$1} (x-a)^$1$0
endsnippet

snippet lim "limit" w
\lim_{${1:n} \to ${2:\infty}} 
endsnippet

snippet limsup "limsup" w
\limsup_{${1:n} \to ${2:\infty}} 
endsnippet

snippet prod "product" w
\prod_{${1:n=${2:1}}}^{${3:\infty}} ${4:${VISUAL}}$0
endsnippet

snippet part "d/dx" w
\frac{\partial ${1:V}}{\partial ${2:x}}$0
endsnippet

context "math()"
snippet sq "\sqrt{}" iA
\sqrt{${1:${VISUAL}}}$0
endsnippet

context "math()"
snippet sr "^2" iA
^2
endsnippet

context "math()"
snippet cb "^3" iA
^3
endsnippet

context "math()"
snippet td "to the ... power" iA
^{$1}$0
endsnippet

context "math()"
snippet rd "to the ... power" iA
^{($1)}$0
endsnippet

snippet __ "subscript" iA
_{$1}$0
endsnippet

snippet ooo "\infty" iA
\infty
endsnippet

snippet rij "mrij" i
(${1:x}_${2:n})_{${3:$2}\\in${4:\\N}}$0
endsnippet

snippet <= "leq" iA
\le 
endsnippet

snippet >= "geq" iA
\ge 
endsnippet

context "math()"
snippet EE "exists" iA
\exists 
endsnippet

context "math()"
snippet AA "forall" iA
\forall 
endsnippet

context "math()"
snippet xnn "xn" iA
x_{n}
endsnippet

context "math()"
snippet ynn "yn" iA
y_{n}
endsnippet

context "math()"
snippet xii "xi" iA
x_{i}
endsnippet

context "math()"
snippet yii "yi" iA
y_{i}
endsnippet

context "math()"
snippet xjj "xj" iA
x_{j}
endsnippet

context "math()"
snippet yjj "yj" iA
y_{j}
endsnippet

context "math()"
snippet xp1 "x" iA
x_{n+1}
endsnippet

context "math()"
snippet xmm "x" iA
x_{m}
endsnippet

priority 100
snippet ... "ldots" iA
\ldots
endsnippet

# snippet table "Table environment by Castel" b
# \begin{table}[${1:htpb}]
# 	\centering
# 	\caption{${2:caption}}
# 	\label{tab:${3:label}}
# 	\begin{tabular}{${5:c}}
# 	$0${5/((?<=.)c|l|r)|./(?1: & )/g}
# 	\end{tabular}
# \end{table}
# endsnippet
#
snippet fig "Figure environment" b
\begin{figure}[${1:htpb}]
	\centering
	${2:\includegraphics[width=0.8\textwidth]{$3}}
	\caption{${4:$3}}
	\label{fig:${5:${3/\W+/-/g}}}
\end{figure}
endsnippet

snippet enum "Enumerate" bA
\begin{enumerate}
	\item $0
\end{enumerate}
endsnippet

snippet item "Itemize" bA
\begin{itemize}
	\item $0
\end{itemize}
endsnippet

snippet desc "Description" b
\begin{description}
	\item[$1] $0
\end{description}
endsnippet

snippet pac "Package" b
\usepackage[${1:options}]{${2:package}}$0
endsnippet

snippet => "implies" Ai
\implies
endsnippet

snippet =< "implied by" Ai
\impliedby
endsnippet

context "math()"
snippet iff "iff" Ai
\iff
endsnippet

# Add ')'
snippet mk "Math revised by ganx" wA
$${1}$`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ')', ' ']:
	snip.rv = ' '
else:
	snip.rv = ''
`$2
endsnippet

snippet dm "Math" wA
\[
    ${1:${VISUAL}}
\] $0
endsnippet

# snippet ali "Align" bA
# \begin{align*}
# 	${1:${VISUAL}}
# \end{align*}
# endsnippet

context "math()"
snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet

snippet / "Fraction" i
\\frac{${VISUAL}}{$1}$0
endsnippet

context "math()"
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "symbol frac" wrA
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
endsnippet

priority 1000
context "math()"
snippet '^.*\)/' "() frac" wrA
`!p
stripped = match.string[:-1]
depth = 0
i = len(stripped) - 1
while True:
	if stripped[i] == ')': depth += 1
	if stripped[i] == '(': depth -= 1
	if depth == 0: break;
	i-=1
snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}"
`{$1}$0
endsnippet

context "math()"
snippet '([A-Za-z])(\d)' "auto subscript" wrA
`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`
endsnippet

context "math()"
snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA
`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`}
endsnippet


snippet sympy "sympyblock " w
sympy $1 sympy$0
endsnippet

priority 10000
snippet 'sympy(.*)sympy' "sympy" wr
`!p
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
init_printing()
snip.rv = eval('latex(' + match.group(1).replace('\\', '').replace('^', '**').replace('{', '(').replace('}', ')') + ')')
`
endsnippet

priority 1000
snippet math "mathematicablock" w
math $1 math$0
endsnippet

priority 10000
snippet 'math(.*)math' "math" wr
`!p
import subprocess
code = match.group(1)
code = 'ToString[' + code + ', TeXForm]'
snip.rv = subprocess.check_output(['wolframscript', '-code', code])
`
endsnippet

snippet == "equals" iA
&= $1 \\\\
endsnippet

snippet != "equals" iA
\neq 
endsnippet

context "math()"
snippet floor "floor" iA
\left\lfloor $1 \right\rfloor$0
endsnippet

snippet bmat "bmat" iA
\begin{bmatrix} $1 \end{bmatrix} $0
endsnippet

priority 100
# snippet * "cdot" iA
# \cdot 
# endsnippet

# priority 200
# snippet '\cdot *' "cdot" iA
# *
# endsnippet

context "math()"
snippet norm "norm" iA
\|$1\|$0
endsnippet

priority 100
context "math()"
snippet '(?<!\\)(sin|cos|arccot|cot|csc|ln|log|exp|star|perp)' "ln" rwA
\\`!p snip.rv = match.group(1)`
endsnippet

priority 200
context "math()"
snippet '(?<!\\)(arcsin|arccos|arctan|arccot|arccsc|arcsec|alpha|beta|delta|Delta|epsilon|lambda|Lambda|phi|pi|rho|tau|theta|Theta|varphi|xi|zeta|int)' "ln" rwA
\\`!p snip.rv = match.group(1)`
endsnippet

# Markdown snippets from
# /dotfiles/vim/plugged/vim-snippets/Ultisnips/markdown.snippets

###########################
# Sections and Paragraphs #
###########################
snippet sec "Section by ganx" b
# ${1:Section Name} {#$1}
$0
endsnippet

snippet ssec "Sub Section by ganx" b
## ${1:Section Name} {#$1}
$0
endsnippet

snippet sssec "SubSub Section by ganx" b
### ${1:Section Name} {#$1}
$0
endsnippet

snippet par "Paragraph" b
#### ${1:Paragraph Name} ####
$0
endsnippet

snippet spar "Paragraph" b
##### ${1:Paragraph Name} #####
$0
endsnippet

###################
# Text formatting #
###################

snippet * "italics"
*${1:${VISUAL}}*$0
endsnippet

snippet ** "bold"
**${1:${VISUAL}}**$0
endsnippet

snippet *** "bold italics"
***${1:${VISUAL}}***$0
endsnippet


################
# Common stuff #
################
snippet link "Link to something"
[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0
endsnippet

snippet img "Image"
![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0
endsnippet

snippet ilc "Inline Code" i
\`$1\`$0
endsnippet

snippet cbl "Codeblock" b
\`\`\`
$1
\`\`\`
$0
endsnippet

snippet refl "Reference Link"
[${1:${VISUAL:Text}}][${2:id}]$0

[$2]:${4:http://${3:www.url.com}} "${5:$4}"
endsnippet

snippet fnt "Footnote"
[^${1:${VISUAL:Footnote}}]$0

[^$1]:${2:Text}
endsnippet

pre_expand "create_table(snip)"
snippet "tb(\d+x\d+)" "Customizable table" br
endsnippet

############################
#  ganxCasteltex.snippets  #
############################

priority 100
context "math()"
snippet -> "to" iA
\to 
endsnippet

priority 200
context "math()"
snippet <-> "leftrightarrow" iA
\leftrightarrow
endsnippet

context "math()"
snippet !> "mapsto" iA
\mapsto 
endsnippet

context "math()"
snippet invs "inverse" iA
^{-1}
endsnippet

context "math()"
snippet compl "complement" iA
^{c}
endsnippet

context "math()"
snippet \\\ "setminus" iA
\setminus
endsnippet

snippet >> ">>" iA
\gg
endsnippet

snippet << "<<" iA
\ll
endsnippet

snippet DD "delta" iA
\Delta 
endsnippet

snippet ~~ "~" iA
\sim 
endsnippet

context "math()"
snippet bs "big set with \middle| by ganx" wA
\\left\\{$1 \middle| $2\\right\\}$0
endsnippet

context "math()"
snippet s| "small set with | by ganx" wA
\\{$1 \mid $2\\}$0
endsnippet

context "math()"
snippet set "set" wA
\\{$1\\}$0
endsnippet

snippet || "mid" iA
 \mid 
endsnippet


context "math()"
snippet cc "subset" Ai
\subset 
endsnippet

snippet notin "not in " iA
\not\in 
endsnippet

context "math()"
snippet inn "in " iA
\in 
endsnippet

snippet NN "n" iA
\N
endsnippet

snippet Nn "cap" iA
\cap 
endsnippet

snippet UU "cup" iA
\cup 
endsnippet

snippet uuu "bigcup" iA
\bigcup_{${1:i \in ${2: I}}}$0
endsnippet

snippet nnn "bigcap" iA
\bigcap_{${1:i \in ${2: I}}}$0
endsnippet

snippet OO "emptyset" iA
\O
endsnippet

snippet RR "real" iA
\R
endsnippet

snippet QQ "Q" iA
\Q
endsnippet

snippet ZZ "Z" iA
\Z
endsnippet

snippet <! "normal" iA
\triangleleft 
endsnippet

snippet <> "hokje" iA
\diamond 
endsnippet


context "math()"
snippet '(?<!i)sts' "text subscript" irA
_\text{$1}$0
endsnippet

context "math()"
snippet tt "text" iA
\text{$1}$0
endsnippet

context "math()"
snippet case "cases by ganx" bA
\begin{cases}
	$1, & \text{if } $2, \\\\
	$3, & \text{if } $0.
\end{cases}
endsnippet

snippet SI "SI" iA
\SI{$1}{$2}
endsnippet

snippet bigfun "Big function" iA
\begin{align*}
	$1: $2 &\longrightarrow $3 \\\\
	$4 &\longmapsto $1($4) = $0
.\end{align*}
endsnippet

snippet cvec "column vector" iA
\begin{pmatrix} ${1:x}_${2:1}\\\\ \vdots\\\\ $1_${2:n} \end{pmatrix}
endsnippet

priority 10
context "math()"
snippet "bar" "bar" riA
\overline{$1}$0
endsnippet

priority 100
context "math()"
snippet "([a-zA-Z])bar" "bar" riA
\overline{`!p snip.rv=match.group(1)`}
endsnippet

priority 10
context "math()"
snippet "hat" "hat" riA
\hat{$1}$0
endsnippet

priority 100
context "math()"
snippet "([a-zA-Z])hat" "hat" riA
\hat{`!p snip.rv=match.group(1)`}
endsnippet

snippet letw "let omega" iA
Let $\Omega \subset \C$ be open.
endsnippet

# vim:ft=snippets:

# Markdown snippets from
# /dotfiles/vim/plugged/vim-snippets/snippets/markdown.snippets

# Includes octopress (http://octopress.org/) snippets

# The suffix `c` stands for "Clipboard".

#snippet [
#	[${1:text}](http://${2:address})
#snippet [*
#	[${1:link}](${2:`@*`})
#snippet [c
#	[${1:link}](${2:`@+`})
#snippet ["
#	[${1:text}](http://${2:address} "${3:title}")
#snippet ["*
#	[${1:link}](${2:`@*`} "${3:title}")
#snippet ["c
#	[${1:link}](${2:`@+`} "${3:title}")
#snippet [:
#	[${1:id}]: http://${2:url}
#
#snippet [:*
#	[${1:id}]: ${2:`@*`}
#
#snippet [:c
#	[${1:id}]: ${2:`@+`}
#
#snippet [:"
#	[${1:id}]: http://${2:url} "${3:title}"
#
#snippet [:"*
#	[${1:id}]: ${2:`@*`} "${3:title}"
#
#snippet [:"c
#	[${1:id}]: ${2:`@+`} "${3:title}"
#
#snippet ![
#	![${1:alttext}](${2:/images/image.jpg})
#snippet ![*
#	![${1:alt}](${2:`@*`})
#snippet ![c
#	![${1:alt}](${2:`@+`})
#snippet !["
#	![${1:alttext}](${2:/images/image.jpg} "${3:title}")
#snippet !["*
#	![${1:alt}](${2:`@*`} "${3:title}")
#snippet !["c
#	![${1:alt}](${2:`@+`} "${3:title}")
#snippet ![:
#	![${1:id}]: ${2:url}
#
#snippet ![:*
#	![${1:id}]: ${2:`@*`}
#
#snippet ![:"
#	![${1:id}]: ${2:url} "${3:title}"
#
#snippet ![:"*
#	![${1:id}]: ${2:`@*`} "${3:title}"
#
#snippet ![:"c
#	![${1:id}]: ${2:`@+`} "${3:title}"
#
#snippet <
#	<http://${1:url}>
#snippet <*
#	<`@*`>
#snippet <c
#	<`@+`>
#snippet **
#	**${1:bold}**
#snippet __
#	__${1:bold}__
#snippet ===
#	`repeat('=', strlen(getline(line('.') - 3)))`
#
#	${0}
#snippet -
#	-   ${0}
#snippet ---
#	`repeat('-', strlen(getline(line('.') - 3)))`
#
#	${0}
#snippet blockquote
#	{% blockquote %}
#	${0:quote}
#	{% endblockquote %}
#
#snippet blockquote-author
#	{% blockquote ${1:author}, ${2:title} %}
#	${0:quote}
#	{% endblockquote %}
#
#snippet blockquote-link
#	{% blockquote ${1:author} ${2:URL} ${3:link_text} %}
#	${0:quote}
#	{% endblockquote %}
#
#snippet ```
#	\`\`\`${1}
#	${0:${VISUAL}}
#	\`\`\`
#
## Language.
#snippet ```l
#	\`\`\`${1:language}
#	${2:code}
#	\`\`\`
#
#snippet codeblock-short
#	{% codeblock %}
#	${0:code_snippet}
#	{% endcodeblock %}
#
#snippet codeblock-full
#	{% codeblock ${1:title} lang:${2:language} ${3:URL} ${4:link_text} %}
#	${0:code_snippet}
#	{% endcodeblock %}
#
#snippet gist-full
#	{% gist ${1:gist_id} ${0:filename} %}
#
#snippet gist-short
#	{% gist ${0:gist_id} %}
#
#snippet img
#	{% img ${1:class} ${2:URL} ${3:width} ${4:height} ${5:title_text} ${0:alt_text} %}
#
#snippet youtube
#	{% youtube ${0:video_id} %}
#
## The quote should appear only once in the text. It is inherently part of it.
## See http://octopress.org/docs/plugins/pullquote/ for more info.
#
#snippet pullquote
#	{% pullquote %}
#	${1:text} {" ${2:quote} "} ${0:text}
#	{% endpullquote %}
